<?php
// Version: 1.2; Groups

function template_main()
{
	global $context, $settings, $options, $scripturl, $txt;

	echo '
	<div style="padding: 3px;">', theme_linktree(), '</div>
		<div class="tborder">
			<div style="padding: 1px;">
				<table width="100%" cellspacing="0" cellpadding="4" border="0">
					<tr class="titlebg">
						<td><a href="' . $scripturl . '?action=helpadmin;help=groups;" onclick="return reqWin(this.href);" class="help"><img src="' . $settings['images_url'] . '/helptopics.gif" alt="' . $txt[119] . '" border="0" align="top" /></a> ' . $txt['groups_title'] . '</td>
					</tr><tr class="windowbg">
						<td class="smalltext" style="padding: 2ex;">', $txt['groups_description'], '</td>
					</tr>
				</table>
			</div>

				<table width="100%" cellpadding="2" cellspacing="1" border="0">
					<tr class="catbg"><td colspan="4" style="padding: 4px;">', $txt['groups_member'], '</td></tr>
					<tr class="titlebg">
						<td width="50%">', $txt['groups_name'], '</td>
						<td width="50%" align="center">', $txt['groups_count'], '</td>
					</tr>';
	foreach ($context['groups']['regular'] as $group)
	{
		echo '
					<tr>
						<td class="windowbg2">', empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>', '</td>
						<td class="windowbg" align="center">', $group['can_search'] ? $group['link'] : $group['num_members'], '</td>
					</tr>';
	}

	echo '
				</table>
		</div>';
}

function template_group_members()
{
	global $context, $settings, $options, $scripturl, $txt;

	echo '
	<div style="padding: 3px;">', theme_linktree(), '</div>
		<form action="', $scripturl, '?action=groups;sa=members;id=', $context['group']['id'], '" method="post">
			<table width="100%" cellpadding="4" cellspacing="1" border="0" class="bordercolor" align="center">
				<tr class="titlebg">
					<td colspan="6" align="left">', $context['page_title'], '</td>
				</tr>
				<tr class="windowbg">
					<td colspan="6" align="left" class="smalltext" style="padding: 2ex;">', $txt['groups_list_desc'], '</td>
				</tr>
				<tr class="catbg">
					<td colspan="6" align="left">', $txt[139], ': ', $context['page_index'], '</td>
				</tr>
				<tr class="titlebg">
					<td><a href="', $scripturl, '?action=groups;sa=members;start=', $context['start'], ';sort=name', $context['sort_by'] == 'name' && $context['sort_direction'] == 'up' ? ';desc' : '', ';id=', $context['group']['id'], '">', $txt[68], $context['sort_by'] == 'name' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>

					<td><a href="', $scripturl, '?action=groups;sa=members;start=', $context['start'], ';sort=active', $context['sort_by'] == 'active' && $context['sort_direction'] == 'up' ? ';desc' : '', ';id=', $context['group']['id'], '">', $txt['attachment_manager_last_active'], $context['sort_by'] == 'active' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>
					<td><a href="', $scripturl, '?action=groups;sa=members;start=', $context['start'], ';sort=registered', $context['sort_by'] == 'registered' && $context['sort_direction'] == 'up' ? ';desc' : '', ';id=', $context['group']['id'], '">', $txt[233], $context['sort_by'] == 'registered' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>
					<td><a href="', $scripturl, '?action=groups;sa=members;start=', $context['start'], ';sort=posts', $context['sort_by'] == 'posts' && $context['sort_direction'] == 'up' ? ';desc' : '', ';id=', $context['group']['id'], '">', $txt[21], $context['sort_by'] == 'posts' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>
					<td width="4%" align="center"><input type="checkbox" class="check" onclick="invertAll(this, this.form);" ', !empty($context['group']['assignable']) ? '' : 'disabled="disabled"', '/></td>
				</tr>';

	if (empty($context['members']))
		echo '
				<tr class="windowbg2">
					<td colspan="6" align="center">', $txt['groups_no_members'], '</td>
				</tr>';

	$alternate = false;
	foreach ($context['members'] as $member)
	{
		echo '
				<tr class="', $alternate ? 'windowbg2' : 'windowbg', '">
					<td>', $member['name'], '</td>
					<td>', $member['last_online'], '</td>
					<td>', $member['registered'], '</td>
					<td>', $member['posts'], '</td>
					<td align="center" width="4%"><input type="checkbox" name="rem[', $member['id'], ']" class="check" ', !empty($context['group']['assignable']) ? '' : 'disabled="disabled"', '/></td>
				</tr>';
		$alternate = !$alternate;
	}

	echo '
				<tr class="titlebg">
					<td colspan="6" align="right">
						<input type="submit" name="remove" value="', $txt['groups_remove'], '" ', !empty($context['group']['assignable']) ? '' : 'disabled="disabled"', ' style="font-weight: normal;" />
					</td>
				</tr>
			</table><br />';

	if (!empty($context['group']['assignable']))
	{
		echo '
			<table width="90%" cellpadding="4" cellspacing="0" border="0" class="tborder" align="center">
				<tr class="titlebg">
					<td align="left" colspan="2">', $txt['groups_add_title'], '</td>
				</tr><tr class="windowbg2">
					<td align="right" width="50%"><b>', $txt['groups_add_desc'], ':</b></td>
					<td align="left">
						<input type="text" name="toAdd" id="toAdd" size="30" />
						<a href="', $scripturl, '?action=findmember;input=toAdd;quote;sesc=', $context['session_id'], '" onclick="return reqWin(this.href, 350, 400);"><img src="', $settings['images_url'], '/icons/assist.gif" border="0" alt="', $txt['find_members'], '" /></a>
					</td>
				</tr><tr class="windowbg2">
					<td colspan="2" align="center">
						<input type="submit" name="add" value="', $txt['groups_add'], '" />
					</td>
				</tr>
			</table>';
	}

	echo '
			<input type="hidden" name="sc" value="', $context['session_id'], '" />
		</form>';
}

?>